<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 创建对象的第二种方式 -->
    <script>
        var obj = new Object();
        obj.name = "张可顺";
        obj.age = 21;
        obj.university = "江苏科技大学";
        obj.sum = function () {
            console.log(11);
        }

        obj[0] = 'off'

        console.log(obj);
        console.log(obj.name);
        console.log(obj['name']);
    </script>

    <!-- 创建对象的第三种方式   -->
    <!--  
 // 格式
// function 构造函数名()  函数名要首字母要大写
// {
//     this.属性=值;
//     this.方法=Function(){}
// }
// 调用 new 构造函数名() 

-->
    <script>
        function Star(name, age, sex) {
            this.name = name;
            this.sex = sex;
            this.age = age;
            this.sum = function () {
                console.log('构造函数');
            }
        }
        var ldh = new Star('刘德华', 18, '男');
        console.log(ldh);
        console.log(ldh['name']);
        ldh.sum();
    </script>
</head>

<body>
</body>

</html>